package com.example.demo.demo.utils;

import java.math.BigInteger;

/**
 * @author: htc
 * @date: Created in 16:36 2018/4/3.
 */
public class Demo {
    public static void main(String[] args) {
        int i;
        Object o = "this is a question";
        System.out.println(o.hashCode());
        System.out.println((o.hashCode()) >>> 16);
        System.out.println((i = o.hashCode()) ^ (i >>> 16));


        String s1 = "ab", s2 = "a" + "b", s3 = "a", s4 = "b", s5 = s3 + s4;
        System.out.println(s1 == s2);
        System.out.println(s1 == s5);
        System.out.println(s5 == s2);
        tet();

        test2();

    }

    public static void tet() {
        System.out.println("############################");
        String s1 = "b2";
        String s2 = "b";
        final String s3 = "b";
        String s33 = new String("b");
        String s4 = s2 + 2;
        String s5 = s3 + 2;
        String s6 = s33 + 2;
        String s7 = "b" + 2;
        System.out.println(s1 == s4);
        System.out.println(s1 == s5);
        System.out.println(s1 == s6);
        System.out.println(s1 == s7);
    }

    public static void test2(){
        System.out.println("十六位二进制换算");
        int s = 32896;
        //十六位二进制
        System.out.println(new BigInteger(String.valueOf(s)).toString(2));

        //低八位值
        int low = s & 0xff;
        System.out.println(low);

        //高八位值
        int high = s >>> 8;
        System.out.println(high);
    }
}
